blob: d2dc7797ef7300c7cd998a45ff96141fbdca9cd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// ==========================================
// app/api/tbe/sessions/[sessionId]/vendor-remarks/route.ts
// ==========================================
import { NextRequest, NextResponse } from "next/server"
import { getServerSession } from "next-auth"
import { authOptions } from "@/app/api/auth/[...nextauth]/route"
import { updateVendorRemarks } from "@/lib/tbe-last/vendor-tbe-service"
interface Props {
params: {
sessionId: string
}
}
// PUT: 벤더 의견 업데이트
export async function PUT(
request: NextRequest,
{ params }: Props
) {
try {
const session = await getServerSession(authOptions)
if (!session?.user?.companyId) {
return NextResponse.json(
{ error: "Unauthorized" },
{ status: 401 }
)
}
const vendorId = typeof session.user.companyId === 'string'
? parseInt(session.user.companyId)
: session.user.companyId
const sessionId = parseInt(params.sessionId)
const body = await request.json()
const { remarks } = body
if (!remarks) {
return NextResponse.json(
{ error: "Remarks are required" },
{ status: 400 }
)
}
const updated = await updateVendorRemarks(sessionId, vendorId, remarks)
return NextResponse.json(updated)
} catch (error) {
console.error("Update remarks error:", error)
return NextResponse.json(
{ error: "Failed to update remarks" },
{ status: 500 }
)
}
}
|